Skip to content

[msbuild/dotnet] Use 'SdkIsSimulator' instead of 'ComputedPlatform'.#25234

Draft
rolfbjarne wants to merge 7 commits intomainfrom
dev/rolf/msbuild-computedplatform
Draft

[msbuild/dotnet] Use 'SdkIsSimulator' instead of 'ComputedPlatform'.#25234
rolfbjarne wants to merge 7 commits intomainfrom
dev/rolf/msbuild-computedplatform

Conversation

@rolfbjarne
Copy link
Copy Markdown
Member

This simplifies the code, since we only have a single property as the source
of truth whether we're building for the simulator or not.

This simplifies the code, since we only have a single property as the source
of truth whether we're building for the simulator or not.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces uses of $(ComputedPlatform) with $(SdkIsSimulator) across MSBuild and SDK-style targets to make simulator-vs-device detection rely on a single source of truth.

Changes:

  • Updated multiple MSBuild target conditions to use $(SdkIsSimulator) instead of $(ComputedPlatform).
  • Moved/added ComputedPlatform definition into dotnet/targets/Xamarin.Shared.Sdk.props for compatibility with external consumers.
  • Removed the old ComputedPlatform initialization snippet from Xamarin.Shared.Sdk.DefaultItems.targets.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/monotouch-test/dotnet/shared.csproj Uses SdkIsSimulator for defining AOT in test builds.
tests/ComputeRegistrarConstant.targets Uses SdkIsSimulator to compute dynamic registrar constant for iOS/tvOS.
msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Common.After.targets Uses SdkIsSimulator to gate IPA/dSYM copy-back steps from the Mac build host.
msbuild/Xamarin.Shared/Xamarin.iOS.Common.targets Uses SdkIsSimulator to gate iTunes metadata/artwork targets.
msbuild/Xamarin.Shared/Xamarin.Shared.targets Uses SdkIsSimulator to gate _PrepareResourceRules.
msbuild/Xamarin.Shared/Xamarin.Shared.props Removes ComputedPlatform computation and switches certain defaults to SdkIsSimulator.
dotnet/targets/Xamarin.Shared.Sdk.targets Uses SdkIsSimulator for link-mode defaults previously keyed off ComputedPlatform.
dotnet/targets/Xamarin.Shared.Sdk.props Exposes SdkIsSimulator and redefines ComputedPlatform for compatibility.
dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets Removes the previous ComputedPlatform initialization block.

Comment thread msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Common.After.targets Outdated
Comment thread msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Common.After.targets Outdated
Comment thread dotnet/targets/Xamarin.Shared.Sdk.props Outdated
Comment thread msbuild/Xamarin.Shared/Xamarin.iOS.Common.targets Outdated
Comment thread msbuild/Xamarin.Shared/Xamarin.iOS.Common.targets Outdated
Comment thread msbuild/Xamarin.Shared/Xamarin.iOS.Common.targets Outdated
Comment thread msbuild/Xamarin.Shared/Xamarin.Shared.targets Outdated
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

rolfbjarne and others added 5 commits April 30, 2026 11:52
Only set ComputedPlatform for iOS and tvOS (like the old behavior).
Introduce a new SdkIsDevice property that's set to true when building
for device (iOS and tvOS only), and use it to retain the original
behavior of ComputedPlatform == 'iPhone' wherever needed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #1892441] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 1892441b883e37c2506a4f342cd2781d376d2e42 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #1892441] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 1892441b883e37c2506a4f342cd2781d376d2e42 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 1892441b883e37c2506a4f342cd2781d376d2e42 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [CI Build #1892441] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 1892441b883e37c2506a4f342cd2781d376d2e42 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to simplify simulator/device detection in the Apple-platform MSBuild tooling by replacing ComputedPlatform checks with SdkIsSimulator and a new SdkIsDevice property, establishing a single source of truth for “device vs simulator” decisions.

Changes:

  • Added SdkIsDevice and updated ComputedPlatform compatibility behavior in the .NET SDK props.
  • Replaced ComputedPlatform conditions with SdkIsSimulator / SdkIsDevice across several targets and test build logic.
  • Documented the new SdkIsDevice MSBuild property and updated contributor guidance to check docs when introducing new properties.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/monotouch-test/dotnet/shared.csproj Switches AOT define condition from ComputedPlatform to SdkIsDevice.
tests/ComputeRegistrarConstant.targets Uses SdkIsSimulator instead of ComputedPlatform to decide dynamic registrar.
msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Common.After.targets Replaces ComputedPlatform device gating for IPA/dSYM copy with SdkIsDevice.
msbuild/Xamarin.Shared/Xamarin.iOS.Common.targets Gates iTunes metadata/artwork targets using SdkIsDevice instead of ComputedPlatform.
msbuild/Xamarin.Shared/Xamarin.Shared.targets Updates _PrepareResourceRules condition to use SdkIsDevice.
msbuild/Xamarin.Shared/Xamarin.Shared.props Removes ComputedPlatform computation and updates multiple conditions to use SdkIsSimulator/SdkIsDevice.
dotnet/targets/Xamarin.Shared.Sdk.targets Updates library link-mode decisions to use SdkIsSimulator.
dotnet/targets/Xamarin.Shared.Sdk.props Introduces SdkIsDevice and defines ComputedPlatform compatibility based on simulator/device.
dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets Removes the previous ComputedPlatform defaulting block.
docs/building-apps/build-properties.md Adds documentation for SdkIsDevice.
.github/copilot-instructions.md Adds guidance to update docs when introducing new MSBuild properties.

Comment on lines +151 to +156
<!-- SdkIsDevice is true when building for device (which can only happen on iOS and tvOS). -->
<SdkIsDevice Condition="'$(SdkIsSimulator)' != 'true' And ('$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS')">true</SdkIsDevice>

<!-- We don't use the 'ComputedPlatform' property anymore, but it seems like there's code out there that depends on it (according to a search on GitHub at least), so define it like we did when we used the property. -->
<ComputedPlatform Condition="'$(ComputedPlatform)' == '' And '$(SdkIsSimulator)' == 'true'">iPhoneSimulator</ComputedPlatform>
<ComputedPlatform Condition="'$(ComputedPlatform)' == '' And '$(SdkIsDevice)' == 'true'">iPhone</ComputedPlatform>
Comment on lines 98 to 104
<!-- We can archive: -->
<!-- macOS and Mac Catalyst: executable projects which aren't app extensions -->
<!-- iOS, tvOS and watchOS: executable projects built for device which aren't app extensions nor watch apps -->
<!-- iOS, tvOS and watchOS: executable projects built for device which aren't app extensions -->
<_CanArchive>false</_CanArchive>
<_CanArchive Condition="('$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst') And '$(OutputType)' == 'Exe' And '$(IsAppExtension)' == 'false'">true</_CanArchive>
<_CanArchive Condition="('$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS' Or '$(_PlatformName)' == 'watchOS') And '$(OutputType)' == 'Exe' And '$(ComputedPlatform)' == 'iPhone' And '$(IsAppExtension)' == 'false' And '$(IsWatchApp)' == 'false'">true</_CanArchive>
<_CanArchive Condition="'$(OutputType)' == 'Exe' And '$(SdkIsDevice)' == 'true' And '$(IsAppExtension)' == 'false'">true</_CanArchive>

<_CanArchive>false</_CanArchive>
<_CanArchive Condition="('$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst') And '$(OutputType)' == 'Exe' And '$(IsAppExtension)' == 'false'">true</_CanArchive>
<_CanArchive Condition="('$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS' Or '$(_PlatformName)' == 'watchOS') And '$(OutputType)' == 'Exe' And '$(ComputedPlatform)' == 'iPhone' And '$(IsAppExtension)' == 'false' And '$(IsWatchApp)' == 'false'">true</_CanArchive>
<_CanArchive Condition="'$(OutputType)' == 'Exe' And '$(SdkIsDevice)' == 'true' And '$(IsAppExtension)' == 'false'">true</_CanArchive>
Comment on lines 124 to +136
@@ -153,7 +133,7 @@ Copyright (C) 2020 Microsoft. All rights reserved.
<!-- Disable dsymutil on desktop unless archiving -->
<NoDSymUtil Condition="'$(NoDSymUtil)' == '' And ('$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst') And '$(ArchiveOnBuild)' != 'true'">true</NoDSymUtil>
<!-- Disable dsymutil for simulator builds by default -->
<NoDSymUtil Condition="'$(NoDSymUtil)' == '' And ('$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS' Or '$(_PlatformName)' == 'watchOS') And '$(ComputedPlatform)' != 'iPhone'">true</NoDSymUtil>
<NoDSymUtil Condition="'$(NoDSymUtil)' == '' And '$(SdkIsSimulator)' == 'true'">true</NoDSymUtil>
Comment on lines +1239 to +1244
This property is a read-only property (setting it will have no effect) that
specifies whether we're building for a device or not.

This property is only `true` when building for an iOS or tvOS device (i.e.,
when `SdkIsSimulator` is not `true` and the platform is iOS or tvOS). It is
not set for macOS or Mac Catalyst builds.
@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

🚀 [CI Build #1892441] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 156 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ generator: All 5 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 6 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (iOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 12 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 11 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. [attempt 2] Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 1892441b883e37c2506a4f342cd2781d376d2e42 [PR build]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants